<!DOCTYPE html>
<html>
<head>
    <title>新增请假</title>
    <meta charset="utf-8">
    <head th:include="weixin/include :: weixinheader"></head>
    <style>
        #uploaderFiles .weui-uploader__file{
            position: relative;
        }
        #uploaderFiles .weui-uploader__file span.close{
            position: absolute;
            right:0;
            top:0;
            width:25px;
            height:25px;
            border-radius: 50%;
            text-align: center;
            line-height: 20px;
            color:#fff;
            background: #e4393c;
        }
    </style>
</head>
<body class="new-leave" ontouchstart>
	 <form class="form-horizontal m" id="form-teacher-add">
	 <input type="hidden" name="studentNumber" th:value="${studentNumber}">
	 <input type="hidden" name="title" th:value="${title}">
    <div class="weui-panel weui-panel_access">
        <div class="weui-cells__title">新增请假</div>
        <div class="weui-cells weui-cells_form">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <textarea class="weui-textarea" id="content" name="content" placeholder="请输入请假内容" rows="3"></textarea>
                </div>
            </div>
            <div class="line"></div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">开始时间</label></div>
                <div class="weui-cell__bd">
                    <input id="sTime" name="startTime" class="weui-input" type="text" placeholder="请选择日期和时间">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">结束时间</label></div>
                <div class="weui-cell__bd">
                    <input id="eTime" name="endTime" class="weui-input" type="text" placeholder="请选择日期和时间">
                </div>
            </div>
            <div class="line"></div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">审批人</label></div>
                <div class="weui-cell__bd">
                	<input type="hidden" name="teacherNumber" th:value="${teacherNumber}">
                    <input class="weui-input" type="text" th:value="${teacherNumberName}" readonly>
                </div>
            </div>
            <div class="weui-cell" style="border-top:1px solid #F5F5F5;">
                <button class="inSubmit" type="button">立即提交</button>
            </div>
        </div>

    </div>
	</form>
<div th:include="weixin/include :: weixinfooter"></div>
<script>
    //时间
    $("#sTime").datetimePicker({
        title: '请选择开始时间',
        yearSplit: '-',
        monthSplit: '-',
        dateSplit: '',
        times: function () {
            return [  // 自定义的时间
                {
                    values: (function () {
                        var hours = [];
                        for (var i=0; i<24; i++) hours.push(i > 9 ? i : '0'+i);
                        return hours;
                    })()
                },
                {
                    divider: true,  // 这是一个分隔符
                    content: ':'
                },
                {
                    values: (function () {
                        var minutes = [];
                        for (var i=0; i<59; i++) minutes.push(i > 9 ? i : '0'+i);
                        return minutes;
                    })()
                },
                {
                    divider: true,  // 这是一个分隔符
                    content: ''
                }
            ];
        },
        onChange: function (picker, values, displayValues) {
        },
        onOpen: function(p) {

        },
        onClose: function() {

        }
    });
    $("#eTime").datetimePicker({
        title: '请选择结束时间',
        yearSplit: '-',
        monthSplit: '-',
        dateSplit: '',
        times: function () {
            return [  // 自定义的时间
                {
                    values: (function () {
                        var hours = [];
                        for (var i=0; i<24; i++) hours.push(i > 9 ? i : '0'+i);
                        return hours;
                    })()
                },
                {
                    divider: true,  // 这是一个分隔符
                    content: ':'
                },
                {
                    values: (function () {
                        var minutes = [];
                        for (var i=0; i<59; i++) minutes.push(i > 9 ? i : '0'+i);
                        return minutes;
                    })()
                },
                {
                    divider: true,  // 这是一个分隔符
                    content: ''
                }
            ];
        },
        onChange: function (picker, values, displayValues) {
        },
        onOpen: function(p) {

        },
        onClose: function() {

        }
    });
    $(".close").click(function(){
        $(this).parent("li").fadeOut(500);
        setTimeout(function(){
            $(this).parent("li").remove();
        },500);
    });
    
    $(".inSubmit").click(function(){
    	if($("#content").val() == ''){
    		$.toptip('请填写请假内容', 'warning');
    	}else if($("#sTime").val() == ''){
    		$.toptip('请填写请假开始时间', 'warning');
    	}else if($("#eTime").val() == ''){
    		$.toptip('请填写请假结束时间', 'warning');
    	}else{
		    $.post("saveLeave", $('#form-teacher-add').serialize(),function(data){
		    	if(data.code == "0"){
		    		location.href= "leaveList";
		    	}
		    });
    	}
    });
    
</script>

</body>

</html>
